package cn.com.roy.thread.t6_2.singleton_2_1;

public class MyObject {
    private static MyObject myObject;

    private MyObject() {
    }

    //设置同步方法，但是会导致效率太低
    synchronized public static MyObject getInstance() {
        try {
            if (myObject == null) {
                Thread.sleep(3000);
                myObject = new MyObject();
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return myObject;
    }
}
